package cc.orange.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.GridLayoutManager;
import cc.orange.R;
import cc.orange.entity.MsgInfosVideoEntity;
import cc.orange.utils.CircleImageView;
import demo.smart.access.xutlis.util.ZXScreenUtil;


/**
 * Created by CM on 2022/10/25.
 */

public class HomeAdapter extends BaseQuickAdapter<MsgInfosVideoEntity.Data, BaseViewHolder> {
    private int width;
    private int type;
    public HomeAdapter(@Nullable List<MsgInfosVideoEntity.Data> data,int type) {
        super(R.layout.item_home_list, data);
        width = ZXScreenUtil.getScreenWidth() / 2 - 100;
        this.type = type;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MsgInfosVideoEntity.Data item) {
//        ImageView item_hl_img = helper.getView(R.id.item_hl_img);
//        RelativeLayout item_hl_rel1 = helper.getView(R.id.item_hl_rel1);
//        RelativeLayout item_hl_rel2 = helper.getView(R.id.item_hl_rel2); //在线
////        RelativeLayout item_hl_rel3 = helper.getView(R.id.item_hl_rel3); //定位
////        helper.setText(R.id.home_frag_text4,item.getWomanName());//名称
//        helper.setText(R.id.home_frag_text4,item.getSocVideo().getTitle());//内容
//        helper.setText(R.id.home_frag_text6,"");//d定位
//
//        CardView item_home_card = helper.getView(R.id.item_home_card);//布局
//       GridLayoutManager.LayoutParams layoutParams = (GridLayoutManager.LayoutParams) item_home_card.getLayoutParams();
//        layoutParams.height  = (int)(width * 1.9);
//        item_home_card.setLayoutParams(layoutParams);
//        if(type != 1) {
//            item_hl_rel1.setVisibility(View.GONE);
//            item_hl_rel2.setVisibility(View.GONE);
//        }else{
//            item_hl_rel1.setVisibility(View.VISIBLE);
//            item_hl_rel2.setVisibility(View.VISIBLE);
//            helper.setText(R.id.item_hl_text1,getClassifyState(item.getSocVideo().getClassify()));//关注 热门 附近
//        }


        RelativeLayout home_frag_rel1 = helper.getView(R.id.home_frag_rel1);//广告
        RelativeLayout home_list_rel1 = helper.getView(R.id.home_list_rel1);//正常布局
        if(item.getAge() == -1){
            home_frag_rel1.setVisibility(View.VISIBLE);
            home_list_rel1.setVisibility(View.GONE);
        }else {
            home_frag_rel1.setVisibility(View.GONE);
            home_list_rel1.setVisibility(View.VISIBLE);
//            RelativeLayout item_hui2_rel = helper.getView(R.id.item_hui2_rel);
//            item_hui2_rel.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    itemClickTalk.itemClickTalk(helper.getLayoutPosition());
//                }
//            });

            helper.setText(R.id.mine_img2, "" + item.getAge()+"");//
            CircleImageView circle_img1 = helper.getView(R.id.circle_img1);
            Glide.with(mContext).load(item.getPhoto())
                    .into(circle_img1);
            helper.setText(R.id.mine_text1, "" + item.getWomanName());
            helper.setText(R.id.mine_text2, "");
            helper.setText(R.id.mine_text3, "" + item.getSignature());
        }
    }


   public interface ItemClickTalk{
        void itemClickTalk(int position);
   }
}
